#include <bits/stdc++.h>

#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int mod = 1e9 + 7;
const double eps = 1e-8;

int T, n, m, k;
LL ans;

struct Node
{
	LL a;
	int cnt, pos;
	
	bool operator< (const Node &t)const
	{
		if (a != t.a) return a < t.a;
		return pos < t.pos;
	}
	void init(LL _a, int _b, int _c)
	{
		a = _a;
		cnt = _b;
		pos = _c;
	}	
};

int main()
{
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cout << fixed <<  setprecision(0);
	
	priority_queue<Node> heap;
	
	cin >> n;
	
	for (int i = 1; i <= n; i ++ )
	{
		LL a;
		cin >> a; 
		
		Node ta;
		
		ta.init(a, 1, i);
		if (a != 1) heap.push(ta);
	}
	
	while (true)
	{
		if (heap.empty()) break;
		Node t = heap.top();
		heap.pop();
		int cnt = t.cnt;
//		cout << t.pos << "!!" << endl;
		
		while (heap.size() && heap.top().a == t.a && abs(heap.top().pos - t.pos) == 1)
		{
			cnt += heap.top().cnt;
			t.pos = heap.top().pos;
			heap.pop();
		}
		
//		cout << t.a << "==" << cnt << "==" << endl;
		
		t.a = sqrt((t.a / 2 + 1)) + eps;
		ans ++ ;
		
//		cout << t.a << "===" << cnt << "==" << t.pos << endl;
		
		if (t.a != 1)
		{
			t.cnt = cnt;
			heap.push(t);
		}
	}
	
	cout << ans << endl;
	
    return 0;
}
/*
7
1 4 2 6 8 5 5
*/